Skip to content

Conversation

frobtech
Copy link
Contributor

@frobtech frobtech commented Feb 5, 2025

Reverts #125763

This causes failures in asan. More thought is needed.

@frobtech frobtech merged commit 66ce716 into main Feb 5, 2025
12 of 13 checks passed
@llvmbot llvmbot added the libc label Feb 5, 2025
@frobtech frobtech deleted the revert-125763-p/libc-stack_chk_fail-test branch February 5, 2025 00:06
@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2025

@llvm/pr-subscribers-libc

Author: Roland McGrath (frobtech)

Changes

Reverts llvm/llvm-project#125763

This causes failures in asan. More thought is needed.


Full diff: https://github.com/llvm/llvm-project/pull/125785.diff

1 Files Affected:

  • (modified) libc/test/src/compiler/stack_chk_guard_test.cpp (+10-15)
diff --git a/libc/test/src/compiler/stack_chk_guard_test.cpp b/libc/test/src/compiler/stack_chk_guard_test.cpp
index d1869a2af412e4..4ec8398c9fc95d 100644
--- a/libc/test/src/compiler/stack_chk_guard_test.cpp
+++ b/libc/test/src/compiler/stack_chk_guard_test.cpp
@@ -12,24 +12,19 @@
 #include "src/string/memset.h"
 #include "test/UnitTest/Test.h"
 
-namespace {
-
 TEST(LlvmLibcStackChkFail, Death) {
   EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
 }
 
-// Disable sanitizers such as asan and hwasan that would catch the buffer
-// overrun before it clobbered the stack canary word.  Function attributes
-// can't be applied to lambdas before C++23, so this has to be separate.  When
-// https://github.com/llvm/llvm-project/issues/125760 is fixed, this can use
-// the modern spelling [[gnu::no_sanitize(...)]] without conditionalization.
-__attribute__((no_sanitize("all"))) void smash_stack() {
-  int arr[20];
-  LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
-}
-
+// Disable the test when asan is enabled so that it doesn't immediately fail
+// after the memset, but before the stack canary is re-checked.
+#ifndef LIBC_HAS_ADDRESS_SANITIZER
 TEST(LlvmLibcStackChkFail, Smash) {
-  EXPECT_DEATH(smash_stack, WITH_SIGNAL(SIGABRT));
+  EXPECT_DEATH(
+      [] {
+        int arr[20];
+        LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
+      },
+      WITH_SIGNAL(SIGABRT));
 }
-
-} // namespace
+#endif // LIBC_HAS_ADDRESS_SANITIZER

Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
…san, hwasan" (llvm#125785)

Reverts llvm#125763

This causes failures in asan. More thought is needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants